//
//  GestureImageView.m
//  UI07_HomeWork
//
//  Created by Bodi on 16/6/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "GestureImageView.h"
#import "ViewController.h"

@implementation GestureImageView


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithImage:(UIImage *)image withFrame:(CGRect)frame{
    self = [super initWithImage:image];
    if (self) {
        self.userInteractionEnabled = YES;
        self.frame = frame;
        [self addTap];
    }
    return  self;

}
- (void)addTap {
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
    
    /** 设置几个手指头点击, 默认一个. */
    tap.numberOfTouchesRequired = 1;
    
    /** 设置点击几下 */
    tap.numberOfTapsRequired = 1;
    
    
    
    [self addGestureRecognizer:tap];
    [tap release];
    
    
}
- (void)tapAction:(UIGestureRecognizer *)tap{
    [self.delegate call];
    
    
    
}



@end
